********Table I.2********

eststo clear

*Load data and create differences
cd "$reploc/data/created_data"
use indo_full, clear

sort pidlink ifls
drop if ifls==.
keep if panel==1


keep rbuc*  gambleaverse ifls pidlink inflation imp_age panel biryear_impl grbrprovAvg_lam0 grbrprovSD_lam0 grbrprovAvg_lam0co? grbrprovSD_lam0co? birprov_impl

*Generate gamble averse due to risk or complexity, etc

gen gambleaverse_risk=.
replace gambleaverse_risk=1 if rbucgaref3a!=. & rbuc==5
replace gambleaverse_risk=0 if ((rbuc!=. & rbucgaref3a==.) | rbuc<=4)

gen gambleaverse_others=.
replace gambleaverse_others=1 if rbucgaref3a==. & rbuc==5
replace gambleaverse_others=0 if ((rbuc!=. & rbucgaref3a!=.) | rbuc<=4)


reshape wide rbuc*  gambleaverse* inflation imp_age panel grbrprovAvg_lam0 grbrprovSD_lam0 grbrprovAvg_lam0co? grbrprovSD_lam0co?, i(pidlink) j(ifls)

local varlist1 rbuc rbucB rbuc_nga rbuc_garefined rbucgaref1a rbucgaref2a rbucgaref3a rbucgaref4a gambleaverse gambleaverse_others gambleaverse_risk inflation grbrprovAvg_lam0 grbrprovSD_lam0 grbrprovAvg_lam0co2 grbrprovSD_lam0co2 grbrprovAvg_lam0co3 grbrprovSD_lam0co3 


foreach var in `varlist1'  {
gen `var'dif=.
replace `var'dif=`var'5-`var'4
}

*Generate cohort by birthyear variables to cluster on
egen coh_prov_clust=group(biryear_impl birprov_impl)

*Regressions
local depvar gambleaverse gambleaverse_risk gambleaverse_others
local rhsvari oldindoonly
local rhsvaruse _lam0co3dif
local usei grbr

foreach x in `depvar' {

preserve

drop if `x'dif==.

eststo:  reg `x'dif  `usei'provAvg`rhsvaruse' `usei'provSD`rhsvaruse'  inflationdif, vce(cluster coh_prov_clust)

restore

}

cd "$reploc/results"	
esttab using TableI2.tex, star(* 0.1 ** 0.05 *** 0.01) b(2) se(2) replace
